package com.heima.article.controller.v1;

import com.heima.article.service.ApArticleService;
import com.heima.model.article.pojos.ApArticle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 文章控制层
 */
@RestController
@RequestMapping("/api/v1/article")
public class ApArticleController  {

    @Autowired
    private ApArticleService apArticleService;
    //新增文章
    @PostMapping("/save")

    public ApArticle insertApArticle(@RequestBody ApArticle apArticle) {
        apArticleService.save(apArticle);
        //返回的apArticle应该包含id,因为我们集成了雪花算法
        return apArticle;
    }
}
